﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using MyLib;
using System.Web;

using Portal.Entity;
using Portal.Interface;

namespace Portal.Logic
{

    public class UserLogic
    {

        public UserEntity GetUserEntity(string userID)
        {
            return DataAccess.Instance("BizDB").GetEntity<UserEntity>("select * from COM_USER where USERID="+userID);
        }
        public UserEntity GetUserEntityByJob(string jobID)
        {
            return DataAccess.Instance("BizDB").GetEntity<UserEntity>("select a.* from COM_USER a inner join COM_JOB b on a.USERID=b.USERID and b.JOBID="+jobID);
        }
        public void Insert(UserEntity user)
        {
            DataAccess.Instance("BizDB").GetEntity<UserEntity>("UserLogic_Insert" ,user);
        }
        public void Update(UserEntity user)
        {
            DataAccess.Instance("BizDB").GetEntity<UserEntity>("UserLogic_Update", user);
        }
        public void Delete(int userID)
        {
            DataAccess.Instance("BizDB").GetEntity<UserEntity>("UserLogic_Delete", userID);
        }


        public JobEntity GetJobEntity(string jobID)
        {
            if (string.IsNullOrEmpty(jobID))
            {
                return new JobEntity();
            }
            else
            {
                return DataAccess.Instance("BizDB").GetEntity<JobEntity>("select * from COM_JOB where JOBID=" + jobID);
            }
        }
        public JobEntity GetJobEntityByUserID(string userID)
        {
            return DataAccess.Instance("BizDB").GetEntity<JobEntity>("select * from COM_JOB where USERID=" + userID);
        }
        public void InsertJob(JobEntity user)
        {
            DataAccess.Instance("BizDB").GetEntity<JobEntity>("UserLogic_InsertJob", user);
        }
        public void UpdateJob(JobEntity user)
        {
            DataAccess.Instance("BizDB").GetEntity<JobEntity>("UserLogic_UpdateJob", user);
        }
        public void DeleteJob(int userID)
        {
            DataAccess.Instance("BizDB").GetEntity<JobEntity>("UserLogic_DeleteJob", userID);
        }
    }
}
